<template>
  <div class="container">
    <persons v-show="visPerson" ref="personsRef" @go="goMethod"></persons>
    <apply-list
      v-show="visApply"
      ref="applyListRef"
      @go="goMethod"
    ></apply-list>
    <apply-detail
      v-show="visApplyDetail"
      ref="applyDetailRef"
      @go="goMethod"
    ></apply-detail>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue';
  import useLoading from '@/hooks/loading';
  import { ApplyVO, PersonInfoVO } from '@/api/subsidy';
  import ApplyList from '@/views/subsidy/enjoy-record/components/applyList.vue';
  import Persons from '@/views/subsidy/enjoy-record/components/persons.vue';
  import ApplyDetail from '@/views/subsidy/enjoy-record/components/applyDetail.vue';

  const generateFormModel = () => {
    return {
      cardId: '',
      page: 1,
      rows: 20,
    };
  };
  const { loading, setLoading } = useLoading();
  const visPerson = ref(true);
  const visApply = ref(false);
  const visApplyDetail = ref(false);
  const person = ref<PersonInfoVO>();
  const apply = ref<ApplyVO>();
  const personsRef = ref();
  const applyListRef = ref();
  const applyDetailRef = ref();

  const goMethod = (str: string, obj1: PersonInfoVO, obj2: ApplyVO) => {
    if (obj1) {
      person.value = obj1;
    }
    if (obj2) {
      apply.value = obj2;
    }
    if (str === '1') {
      visPerson.value = true;
      visApply.value = false;
      visApplyDetail.value = false;
    } else if (str === '2') {
      visPerson.value = false;
      visApply.value = true;
      visApplyDetail.value = false;
      applyListRef.value.handleChangeVisible(person.value);
    } else if (str === '3') {
      visPerson.value = false;
      visApply.value = false;
      visApplyDetail.value = true;
      applyDetailRef.value.handleChangeVisible(person.value, apply.value);
    }
  };
</script>

<style scoped lang="less">
  .container {
    padding: 10px;
  }

  :deep(.arco-table-th) {
    &:last-child {
      .arco-table-th-item-title {
        margin-left: 16px;
      }
    }
  }
</style>
